package zhangxin;

import java.util.ArrayList;
import java.util.List;

interface Student {
    boolean isExcellent();
    void displayInfo();
}

class Undergraduate implements Student {
    private String name;
    private String studentId;
    private double gpa;
    private boolean hasAward;
    public Undergraduate(String name, String studentId, double gpa, boolean hasAward) {
        this.name = name;
        this.studentId = studentId;
        this.gpa = gpa;
        this.hasAward = hasAward;
    }
    @Override
    public boolean isExcellent() {
        return gpa >= 3.5 && hasAward;
    }
    @Override
    public void displayInfo() {
        System.out.println("本科生信息:");
        System.out.println("姓名: " + name);
        System.out.println("学号: " + studentId);
        System.out.println("GPA: " + gpa);
        System.out.println("获得奖项: " + (hasAward ? "是" : "否"));
        System.out.println("是否优秀: " + (isExcellent() ? "是" : "否"));
        System.out.println("------------------------");
    }
    public String getName() { return name; }
    public String getStudentId() { return studentId; }
    public double getGpa() { return gpa; }
    public boolean hasAward() { return hasAward; }
}
class Graduate implements Student {
    private String name;
    private String studentId;
    private String researchDirection;
    private int papersPublished;
    public Graduate(String name, String studentId, String researchDirection, int papersPublished) {
        this.name = name;
        this.studentId = studentId;
        this.researchDirection = researchDirection;
        this.papersPublished = papersPublished;
    }
    @Override
    public boolean isExcellent() {
        return papersPublished >= 2;
    }
    @Override
    public void displayInfo() {
        System.out.println("硕士生信息:");
        System.out.println("姓名: " + name);
        System.out.println("学号: " + studentId);
        System.out.println("研究方向: " + researchDirection);
        System.out.println("发表论文数量: " + papersPublished);
        System.out.println("是否优秀: " + (isExcellent() ? "是" : "否"));
        System.out.println("------------------------");
    }

    // Getter方法
    public String getName() { return name; }
    public String getStudentId() { return studentId; }
    public String getResearchDirection() { return researchDirection; }
    public int getPapersPublished() { return papersPublished; }
}

public class StudentManagement {
    public static void main(String[] args) {
        List<Student> students = new ArrayList<>();
        students.add(new Undergraduate("张三", "2023001", 3.8, true));
        students.add(new Undergraduate("李四", "2023002", 3.2, true));
        students.add(new Undergraduate("王五", "2023003", 3.6, false));
        students.add(new Graduate("赵六", "2024001", "人工智能", 3));
        students.add(new Graduate("钱七", "2024002", "大数据", 1));
        System.out.println("所有学生信息:");
        System.out.println("========================");
        for (Student student : students) {
            student.displayInfo();
        }
        System.out.println("\n优秀学生信息:");
        System.out.println("========================");
        for (Student student : students) {
            if (student.isExcellent()) {
                student.displayInfo();
            }
        }
        int excellentCount = 0;
        for (Student student : students) {
            if (student.isExcellent()) {
                excellentCount++;
            }
        }
        System.out.println("优秀学生总数: " + excellentCount);
    }
}